//
//  CoGeRenderManager.h
//  CoGeOpenSource
//
//  Created by Tamas Nagy on 14/11/13.
//  Copyright (c) 2013 home. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <OpenGL/OpenGL.h>
#import "CoGeRenderer.h"
#import "CoGeCIRenderer.h"

@interface CoGeRenderManager : NSObject {

    NSOpenGLContext *glContext;
    GLuint fbo, depthbuffer;
    GLuint canvasfbo, canvasdepthbuffer;
    GLuint renderbuffer, msaafbo;
    
    NSSize layerSize, canvasSize;
    
    BOOL rebuildlayer, rebuildcanvas;
    
    BOOL needscanvas;
    
    NSSize currentSize;
    
    BOOL caching;
    
    BOOL needsMSAA;
    
    CGLContextObj cgl_ctx;
    
    BOOL useMSAA;
    
    BOOL needsMSAAcached;
    
    
    CGColorSpaceRef colorspace;
    
}

@property (retain, nonatomic) NSOpenGLContext *glContext;
@property (nonatomic) NSSize layerSize;
@property (nonatomic) NSSize canvasSize;
@property (readwrite, nonatomic) BOOL needsMSAA;

+ (CoGeRenderManager *)sharedManager;
-(void)initWithContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pformat;

-(void)renderWithRenderer:(id<CoGeTextureSource>)renderer atTime:(NSTimeInterval)time arguments:(NSDictionary *)args isCoreImageFX:(BOOL)isCI;


-(void)lock;
-(void)unlock;

-(void)renderingSizeChanged;

@end
